/**
 * Created by ritamashin on 2017/11/17.
 */

import * as apis from '../apis'
import {SCREEN_WIDTH} from '../config'


export function getGiftItemDetailWithId(id) {
    return dispatch => {
        apis.getGiftDetailDataWithGiftId(id)
            .then(response => {
                let {code,data, message} = response;
                let htmlString = data["content_html"];

                htmlString = htmlString.replace(/<img/g,`<img width =${SCREEN_WIDTH - 20}, height = ${SCREEN_WIDTH - 20} * 9.0 / 16.0`);
                htmlString = htmlString.replace(/查看详情/g,'');
                htmlString = htmlString.replace(/<p class=\"item-info-price\"/g, '<p style=\"color: red\" size = \"20\" class=\"item-info-price\"');
                htmlString = htmlString.replace(/<p class=\"item-like/g, '<p style= \" font-size : medium \" class=\"item-like' )
                dispatch(appendGiftDetailHtmlString(htmlString));
            })
    }
}




function appendGiftDetailHtmlString(htmlString) {
    return {
        type : 'GIFT_DETAIL_APPEND_HTML_STRING',
        htmlString,
    }
}